"""
客户留言序列化器
"""

from rest_framework import serializers
from pecco_site.models import ContactMessage


class ContactMessageSerializer(serializers.ModelSerializer):
    """客户留言序列化器"""
    message_type_display = serializers.CharField(source='get_message_type_display', read_only=True)
    
    class Meta:
        model = ContactMessage
        fields = [
            'id', 'message_type', 'message_type_display', 'name', 'email',
            'message', 'is_read', 'replied_at', 'created_at', 'updated_at'
        ]
        read_only_fields = ['id', 'created_at', 'updated_at', 'message_type_display']


class ContactMessageDetailSerializer(serializers.ModelSerializer):
    """客户留言详情序列化器"""
    message_type_display = serializers.CharField(source='get_message_type_display', read_only=True)
    
    class Meta:
        model = ContactMessage
        fields = [
            'id', 'message_type', 'message_type_display', 'name', 'email',
            'message', 'is_read', 'replied_at', 'created_at', 'updated_at'
        ]
        read_only_fields = ['id', 'message_type', 'name', 'email', 'message', 'created_at', 'updated_at']

